#{extends 'common/supervisor.html' /}
#{set title:'待付款理财账单列表' /}
<div class="xn_c_contentwarp">
  <div class="xn_c_contentlist">
    #{include "supervisor/financeManager/common/financeManageLeft.control"/}
      <div class="xn_c_content">
	  <div class="xf_ht_tablelist">
		<!-- 搜索 -->
		#{form @toPayBills(), id:'submit'}
		<div class="xf_ht_search">
		  <input type="hidden" id="currPage" name="currPageStr"/>
          <input type="hidden" id="pageSize" name="pageSizeStr"/>
		  <div class="xf_ht_search_l">
			<input type="hidden" id="orderType" name="orderType" value="${page.conditions?.orderType}"/>
			<span id="div_0"><a id="tab_0" onClick="conditonSearch(0)">默认排序<a id="sp0"></a></a></span>
			<span id="div_1"><a id="tab_1" onClick="conditonSearch(1)">应付款时间<a id="sp1">↑</a></a></span>
			<span id="div_3"><a id="tab_3" onClick="conditonSearch(3)">应付款金额<a id="sp3">↑</a></a></span>
			<span id="div_5"><a id="tab_5" onClick="conditonSearch(5)">逾期时长<a id="sp5">↑</a></a></span>
		  </div>
		</div>
		<div class="xf_ht_search_inon">
		  <div class="xf_ht_search_r">
			<div class="xf_ht_search_xl">
			  <select id="year" name="yearStr"  class="xf_membill_selectAge">
				<option value="0" #{if page.conditions?.year == 0} selected="selected" #{/if}>全部</option>
			  </select>
			</div>
			<div class="xf_ht_search_xl">
			  <select id="month" name="monthStr" class="xf_membill_selectAge">
				<option value="0" #{if page.conditions?.month == 0} selected="selected" #{/if}>全部</option>
				<option value="1" #{if page.conditions?.month == 1} selected="selected" #{/if}>1</option>
				<option value="2" #{if page.conditions?.month == 2} selected="selected" #{/if}>2</option>
				<option value="3" #{if page.conditions?.month == 3} selected="selected" #{/if}>3</option>
				<option value="4" #{if page.conditions?.month == 4} selected="selected" #{/if}>4</option>
				<option value="5" #{if page.conditions?.month == 5} selected="selected" #{/if}>5</option>
				<option value="6" #{if page.conditions?.month == 6} selected="selected" #{/if}>6</option>
				<option value="7" #{if page.conditions?.month == 7} selected="selected" #{/if}>7</option>
				<option value="8" #{if page.conditions?.month == 8} selected="selected" #{/if}>8</option>
				<option value="9" #{if page.conditions?.month == 9} selected="selected" #{/if}>9</option>
				<option value="10" #{if page.conditions?.month == 10} selected="selected" #{/if}>10</option>
				<option value="11" #{if page.conditions?.month == 11} selected="selected" #{/if}>11</option>
				<option value="12" #{if page.conditions?.month == 12} selected="selected" #{/if}>12</option>
			  </select>
			</div>
			<div class="xf_ht_search_xl">
			  <select id="select" name="typeStr" class="xf_membill_selectAge">
				<option value="0" #{if page.conditions.type == 0} selected="selected" #{/if}>全部</option>
				<option value="1" #{elseif page.conditions.type == 1} selected="selected" #{/elseif}>借款标编号</option>
				<option value="2" #{elseif page.conditions.type == 2} selected="selected" #{/elseif}>借款人</option>
				<option value="3" #{elseif page.conditions.type == 3} selected="selected" #{/elseif}>账单编号</option>
			  </select>
			</div>
			<div class="xf_ht_search_xl">
				<input type="text" class="search_w" id="key" name="key" value="${page.conditions?.key}">
			</div>
			<div class="xf_ht_search_xl">
				<input type="submit" class="search_button" value="搜索">
			</div>
		  </div>
		</div>
		#{/form}
		<!-- 列表内容 -->
		<div class="xn_c_content_top">
		  #{table class:"xn_c_content_list", cellspacing:"0", cellpadding:"0", border:"0", tr_class_odd:"xn_tr_bj"}
			#{tr}
			  #{th}序号#{/th}
			  #{th}账单编号#{/th}
			  #{th}债权人#{/th}
			  #{th}账单期数#{/th}
			  #{th}应付账单金额#{/th}
			  #{th}账单标题#{/th}
			  #{th}关联借款标编号#{/th}
			  #{th}借款人#{/th}
			  #{th}应付款时间#{/th}
			  #{th}逾期时长#{/th}
			  #{th}历史未付#{/th}
			  #{th}状态#{/th}
			  #{th}借款人客服#{/th}
			  #{th}操作#{/th}
			#{/tr}
			#{list items:page.page, as:'toPay'}
			#{tr tr_index:_index}
			  #{td}${(page?.currPage - 1)*page?.pageSize + toPay_index}#{/td}
			  #{td}${toPay?.bill_no}#{/td}
			  #{td}${toPay?.invest_name}#{/td}
			  #{td}${toPay?.period}#{/td}
			  #{td}${toPay?.pay_amount?.format("###,##0.00")}#{/td}
			  #{td}${toPay?.title}#{/td}
			  #{td}${toPay?.bid_no}#{/td}
			  #{td}${toPay?.name}#{/td}
			  #{td}${toPay?.receive_time?.format('yyyy-MM-dd')}#{/td}
			  #{td}${toPay?.overdue_time}#{/td}
			  #{td}${toPay?.unpaid_bills}#{/td}
			  #{td}
			     #{if toPay?.status == -1} 未收款           #{/if}
			     #{elseif toPay?.status == -2} 逾期未收款   #{/elseif}
			     #{elseif toPay?.status == -5} 待收款           #{/elseif}
			     #{elseif toPay?.status == -6} 逾期待收款   #{/elseif}
			     #{elseif}	 未知状态#{/elseif}		  
			  #{/td}
			  #{td}
				#{if toReceiveBills?.supervisor_name2 == '' || toReceiveBills?.supervisor_name2 == null}
				  #{if toReceiveBills?.supervisor_name == '' || toReceiveBills?.supervisor_name == null}
				          暂无分配
				  #{/if}
				  #{else}
				    ${toReceiveBills?.supervisor_name}
				  #{/else}
				#{/if}
				#{else}
				  ${toReceiveBills?.supervisor_name2}
				#{/else}
			  #{/td}
			  #{td}
			    <span><a href="javascript:showBill('${toPay?.sign}', 8, '${toPay?.status}')" class="xf_ta_onclick">账单详情</a></span>
                <span><a href="@{bidDetail(toPay?.bid_id,8, 500)}" class="xf_ta_onclick">借款标详情</a></span>
			  #{/td}
			#{/tr}
			#{/list}
		  #{/table}
		</div>
		<!-- 列表底部 -->
		<div class="xn_c_content_bottom">
		  <div class="page_warp">
			#{page currPage:page.currPage,totalCount:page.totalCount,pageSize:page.pageSize,theme:2,style:4}#{/page}
		  </div>
		</div>
	  </div>
	</div>
  </div>
</div>
<div id="show"></div>
<script type="text/javascript">
$(function(){
	  var mydate = new Date();
	  var now = mydate.getFullYear();
	  var before = now -5;
	  var html = "";
	  
	  for(var  c = now ;c >= before;c--){
		   html += '<option ';

		   if('${page?.conditions?.year}' == c)
			   html += 'selected="selected"';

		   html += ' value="'+c+'">'+c+'</option>';
	  }

	  $("#year").append(html);
	});

function conditonSearch(num){
	  var orderType= ${page.conditions?.orderType};
	  if(orderType == 0){
	    $("#orderType").val(num);
	    $("#submit").submit();
	    return;
	  }
	  var sum = orderType/2;
	  if(sum.toString().indexOf('.') == -1){
	    var sum2 = orderType - 1;
	    $("#orderType").val(num);
	    $("#submit").submit();
	    return;
	  }else{
	    if(orderType == num){
	      $("#orderType").val(num + 1);
	      $("#submit").submit();
	      return;
	    }else{
	      $("#orderType").val(num);
	      $("#submit").submit();
	      return;
	    }
	  }
	}


  $(function(){	
    /* 高亮显示 */
	showHighLight(3,3,8);
	//条件查询控制样式
	var num= ${page.conditions?.orderType};
    if(num == 0){
      $("#div_0").addClass("xf_sea_isshow");
      
      return;
    }
    var sum = num/2;
    if(sum.toString().indexOf('.') == -1){
      var sum2 = num -1;
      $("#div_"+sum2).addClass("xf_sea_isshow");
      $("#sp"+sum2).html("↓");
      
      return;
    }
    $("#div_"+num).addClass("xf_sea_isshow");
  });
  
  function showPage(currPage, pageSize){
    $("#currPage").val(currPage);
    $("#pageSize").val(pageSize);
    $("#submit").submit();
  }
  
  function showBill(billId, type, status) {
    $.layer({
      type : 2,
      title: '对账单',
      shadeClose: true,
      maxmin: true,
      fix : true,  
      area: ['900', 500],                     
      iframe: {
        src : "@{supervisor.financeManager.PayableBillManager.investBillForPay}?billId="+billId+"&type="+type+"&status="+status
      }
    }); 
  }
</script>
<script type="text/javascript" src="@{'/public/javascripts/tab/tab_mg_bill.js'}"></script>